package com.xja.controller;

import com.xja.entity.Users;
import com.xja.service.UserService;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/user")
public class UserController {
    private Logger logger = LoggerFactory.getLogger(UserController.class);
    @Reference(url = "dubbo://localhost:20881")
    @Autowired(required = false)
    private UserService userService;

    @RequestMapping("/login")
    public String login(Users users){
        System.out.println(userService);
        Users users1 = userService.login(users);
        System.out.println(users1.getLoginName());
        if(users1!=null){
            System.out.println(users1.getId());
            if(users1.getId()==1){
                return "food_add";
            }
            return "";
        }
        return "redirect:/login.html";
    }
}
